package net.lab1024.sa.admin.module.business.ball.job;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.module.business.ball.service.BallService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class FuliBallSpider{
    private boolean hasRun = false;

    private final BallService ballService;

    @Scheduled(cron = "0 0 1 * * ?")
    public void execute() {
        if (!hasRun) {
            hasRun = true;
            try {
                ballService.updateDbColorBall();
                hasRun = false;
            } catch (Exception e) {
                log.error("更新数据异常！：" + e.getMessage(), e);
                hasRun = false;
            }
        }
    }
}
